import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import router from './router'
import { registerDirectives } from './directives'

// 引入dayjs及中文语言包
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'

// 导入全局样式
import './assets/styles/global.scss'
import './assets/main.css'

const app = createApp(App)

app.use(createPinia())
app.use(router)
// 设置dayjs为中文
dayjs.locale('zh-cn')

// 注册全局指令
registerDirectives(app)

// 使用Element Plus并设置为中文
app.use(ElementPlus, {
  locale: zhCn
})

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.mount('#app')
